<?php
App::uses('AppModel', 'Model');
/**
 * Modified by Vu 17/05/2013
 *
 * Department Model
 *
 * @property MailList $MailList
 */
class Department extends AppModel {

/**
 * Validation rules
 *
 * @var array
 */
	public $validate = array(
		'name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
			),
            'unique_dep'=> array(
                'rule'=> 'isUnique',
                'message'=> 'This department already exists. Please choose a different department.',
            ),
            'letters_numbers'=> array(
                'rule'=> 'alphaNumeric',
                'message'=> 'Only letters and numbers allowed.',
            ),
            'character_length'=> array(
                'rule' => array('maxLength', 30),
                'message' => 'A maximum of 30 characters can be entered.'
            ),
		),

		'dept_desc' => array(
			'notempty' => array(
				'rule' => array('notempty'),
			),
            'character_length'=> array(
                'rule' => array('maxLength', 70),
                'message' => 'A maximum of 70 characters can be entered.'
            )
		),

		'email' => array(
			'email' => array(
				'rule' => array('email'),
			),
            'unique_email'=> array(
                'rule'=> 'isUnique',
                'message'=> 'E-mail already in use. Please choose a different email address.',
            ),
		),
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * hasMany associations
 *
 * @var array
 */
	public $hasMany = array(
		'MailList' => array(
			'className' => 'MailList',
			'foreignKey' => 'department_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);

}
